{% extends 'base.html' %}

{% block title %}首页{% endblock %}

{% block main %}
    <h2 class="text-center">博客列表</h2>
    <style>
        /* 博客列表页标题链接样式 */
        .card-header a {
            color: #000 !important; /* 强制默认黑色 */
            text-decoration: none;
            transition: color 0.2s; /* 平滑过渡 */
        }

        /* 标题链接 hover 效果 */
        .card-header a:hover {
            color: #0066cc !important; /* 强制 hover 蓝色 */
            text-decoration: underline; /* 可选：添加下划线提示 */
        }
    </style>
    <div class="row row-cols-2 row-gap-4">
        {% for blog in blogs %}
            <div class="col">
                <div class="card">
                    <div class="card-header bg-white">
                        <a href="{% url 'blog:blog_detail' blog_id=blog.id %}" class="text-dark fs-5 fw-semibold">
                            {{ blog.title }}
                        </a>
                    </div>
                    <div class="card-body" style="height: auto; padding: 1.25rem;">
                        <p class="card-text text-muted">
                            {{ blog.content|striptags|truncatechars:120 }}
                        </p>
                    </div>
                    <div class="card-footer bg-transparent d-flex justify-content-between align-items-center">
                        <div>
                            <img src="{{ blog.author.profile.avatar.url }}" class="rounded-circle" width="32" height="32" alt="">
                            {{ blog.author.profile.nickname|default:blog.author.username }}
                        </div>
                        <div class="text-sm text-muted">发布时间：{{ blog.pub_time|date:"Y年m月d日 H时i分"}}</div>
                    </div>
                </div>
                <style>
                    .card:hover {
                        transform: translateY(-3px); /* 轻微上浮 */
                        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); /* 阴影加深 */
                    }

                    .card-header a:hover {
                        color: #2c3e50; /* 标题hover加深 */
                        text-decoration: underline;
                    }
                </style>
            </div>
        {% endfor %}
    </div>
{% endblock %}


